Add new format 'VidaOne'.
authoroliskoli <oliskoli>
Sat, 26 Apr 2008 10:49:34 +0000 (10:49 +0000)
committeroliskoli <oliskoli>
Sat, 26 Apr 2008 10:49:34 +0000 (10:49 +0000)
Makefile.in
testo
vecs.c
vidaone.c [new file with mode: 0644]

index 03c5a28113cbd5422e9eda48149a70089a4e38f8..7da093f414d4c8b8047181379380987d35d458f3 100644 (file)
@@ -58,7 +58,7 @@ ALL_FMTS=$(MINIMAL_FMTS) gtm.o gpsutil.o pcx.o cetus.o copilot.o \
        yahoo.o unicsv.o wfff_xml.o garmin_txt.o axim_gpb.o gpssim.o \
        wbt-200.o stmsdf.o gtrnctr.o dmtlog.o raymarine.o alan.o vitovtt.o \
        ggv_log.o g7towin.o garmin_gpi.o lmx.o random.o xol.o dg-100.o \
-       navilink.o mtk_logger.o ik3d.o osm.o destinator.o exif.o
+       navilink.o mtk_logger.o ik3d.o osm.o destinator.o exif.o vidaone.o
 
 FMTS=@FMTS@
 
@@ -724,6 +724,8 @@ vcf.o: vcf.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \
   jeeps/gpsrqst.h jeeps/gpsinput.h jeeps/gpsproj.h
 vecs.o: vecs.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \
   gbfile.h cet.h cet_util.h inifile.h csv_util.h
+vidaone.o: vidaone.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \
+  zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h
 vitosmt.o: vitosmt.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \
   zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h grtcirc.h
 vitovtt.o: vitovtt.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \
diff --git a/testo b/testo
index 45e8c40162c833561a989f416144e092a2c91ff9..b6a9a4ed7f1ff1bee0d4158456ed820e351f3b87 100755 (executable)
--- a/testo
+++ b/testo
@@ -1327,5 +1327,9 @@ compare ${TMPDIR}/destinator_trl.txt ${REFERENCE}/track/destinator_trl.txt
 ${PNAME} -i exif -f ${REFERENCE}/IMG_2065.JPG -o unicsv,utc=0 -F ${TMPDIR}/exif-dat.csv
 compare ${TMPDIR}/exif-dat.csv ${REFERENCE}/exif-dat.csv
 
+# VidaOne track logs
+${PNAME} -i vidaone -f ${REFERENCE}/track/vidaone.gpb -t -o unicsv -F ${TMPDIR}/vidaone.csv
+compare ${TMPDIR}/vidaone.csv ${REFERENCE}/track/vidaone.csv
+
 
 exit 0
diff --git a/vecs.c b/vecs.c
index 370d0e60ba9c27f8c36e6e3007e2453c37eea592..bca12ebebb2b6ef941bd154a4e90876eaa4e72f8 100644 (file)
--- a/vecs.c
+++ b/vecs.c
@@ -136,6 +136,7 @@ extern ff_vecs_t destinator_poi_vecs;
 extern ff_vecs_t destinator_trl_vecs;
 extern ff_vecs_t destinator_itn_vecs;
 extern ff_vecs_t exif_vecs;
+extern ff_vecs_t vidaone_vecs;
 
 static
 vecs_t vec_list[] = {
@@ -767,6 +768,12 @@ vecs_t vec_list[] = {
                 "Embedded Exif-GPS data (.jpg)",
                "jpg"
         },
+        {
+                &vidaone_vecs,
+                "vidaone",
+                "VidaOne track logs (.gpb)",
+               "gpb"
+        },
 #endif // MAXIMAL_ENABLED
        {
                NULL,
diff --git a/vidaone.c b/vidaone.c
new file mode 100644 (file)
index 0000000..40904d7
--- /dev/null
+++ b/vidaone.c
@@ -0,0 +1,134 @@
+/*
+
+    Support for "VidaOne Diet & Fittness" data files (.gpb)
+
+    Copyright (C) 2008 Olaf Klein, o.b.klein@gpsbabel.org
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+
+ /*
+    Simple layout:
+
+       struct
+       {
+               double dLatitude
+               double dLongitude
+               float fReserved
+       };
+ */
+#include "defs.h"
+#include <ctype.h>
+#include <math.h>
+
+#define MYNAME "vidaone"
+
+static
+arglist_t vidaone_args[] = {
+       ARG_TERMINATOR
+};
+
+static gbfile *fin, *fout;
+
+/*******************************************************************************
+* %%%        global callbacks called by gpsbabel main process              %%% *
+*******************************************************************************/
+
+static void
+vidaone_rd_init(const char *fname)
+{
+       fin = gbfopen(fname, "rb", MYNAME);
+}
+
+static void 
+vidaone_rd_deinit(void)
+{
+       gbfclose(fin);
+}
+
+static void
+vidaone_read(void)
+{
+       route_head *trk = NULL;
+       
+       while (! gbfeof(fin)) {
+               waypoint *wpt = waypt_new();
+
+               wpt->latitude = gbfgetdbl(fin);
+               wpt->longitude = gbfgetdbl(fin);
+               (void) gbfgetflt(fin);
+               
+               /* Only one basic check of data integrity */
+               if ((fabs(wpt->latitude) > 90) || (fabs(wpt->longitude) > 180))
+                       fatal(MYNAME ": Latitude and/or longitude out of range.\n");
+
+               if (!trk) {
+                       trk = route_head_alloc();
+                       track_add_head(trk);
+               }
+
+               track_add_wpt(trk, wpt);
+       }
+}
+
+static void
+vidaone_wr_init(const char *fname)
+{
+       fout = gbfopen(fname, "wb", MYNAME);
+}
+
+static void
+vidaone_wr_deinit(void)
+{
+       gbfclose(fout);
+}
+
+static void
+vidaone_trkpt(const waypoint *wpt)
+{
+       gbfputdbl(wpt->latitude, fout);
+       gbfputdbl(wpt->longitude, fout);
+       gbfputflt(0, fout);
+}
+
+static void
+vidaone_write(void)
+{
+       track_disp_all(NULL, NULL, vidaone_trkpt);
+}
+
+/**************************************************************************/
+
+ff_vecs_t vidaone_vecs = {
+       ff_type_file,
+       { 
+               ff_cap_none                     /* waypoints */, 
+               ff_cap_read | ff_cap_write      /* tracks */, 
+               ff_cap_none                     /* routes */
+       },
+       vidaone_rd_init,        
+       vidaone_wr_init,        
+       vidaone_rd_deinit,      
+       vidaone_wr_deinit,      
+       vidaone_read,
+       vidaone_write,
+       NULL,
+       vidaone_args,
+       CET_CHARSET_UTF8, 1
+};
+
+/**************************************************************************/